<layout name="layout" />
<link rel="stylesheet" href="/Css/ranking.css" type="text/css">
<div class="pageheader">
    <h1 class="pagetitle">
        <a href="/" class="linkWay">首页 / 新增卡位</a>
        &nbsp;<span class="divider">»</span>&nbsp;
        <a href="/shortcut/ranking_choose" class="linkWay choosse_ranking">选择卡位</a>
        &nbsp;<span class="divider">»</span>&nbsp;
        <a href="javascript:" class="linkWay campaigns_page">选择需要卡位的计划</a>
        &nbsp;<span class="divider">»</span>&nbsp;
        <a href="javascript:" class="linkWay adgroup_page">选择需要卡位的推广组</a>
        &nbsp;<span class="divider">»</span>&nbsp;
        <a href="javascript:" class="linkWay previous_page" >选择需要卡位的关键词</a>
        &nbsp;<span class="divider">»</span>&nbsp;
        <a href="#" class="currentWay">设置卡位规则</a>
    </h1>
</div>
<div id="contentwrapper" class="contentwrapper nopadding">
    <div id="rules_manager">

        <table class="keywords metrotable datatable">
            <thead>
            <tr>
                <th width="20%" class="head1">推广计划</th>
                <th width="20%" class="head0">推广组</th>
                <th width="15%" class="head1">关键词</th>
                <th width="10%" class="head0 real_time_ranking">实时排名</th>
                <th width="10%" class="head1">期望排名</th>
                <th width="10%" class="head0">当前出价</th>
                <th width="15%" class="head1">操作</th>
            </tr>
            </thead>
            <tbody></tbody>
        </table>
        <div class="topSetting">
            <div class="setting-base kawei-ranking">
                <div class="option-name">批量期望排名设置：</div>
                <div class="option-content">
                    <select name="rankingValue"></select>
                </div>
            </div>
            <div class="setting-base kawei-rate">
                <div class="option-name">卡位频率设置：</div>
                <div class="option-content">
                    <select name="rateType">
                        <option value="5">5分钟</option>
                        <option value="10">10分钟</option>
                        <option value="15">15分钟</option>
                        <option value="30" selected="selected">30分钟</option>
                        <option value="60">60分钟</option>
                    </select>
                    <div style="display:none;">
                        <input type="text" name="kawei-rateValue">
                        <span class="add-on">分钟</span>
                    </div>
                </div>
            </div>
            <!--<div class="setting-base kawei-time-section">
                <div class="option-name">卡位时间区间：</div>
                <div class="option-content">
                    <input type="datetime-local" id="section-from" name="from">~<input type="datetime-local" id="section-to" name="to">
                </div>
            </div>-->
            <div class="setting-base h80 kawei-premium">
                <div class="option-name">溢价设置：</div>
                <div class="option-content">
                    <div>
                        <div style="display:inline-block;float:left">在原价基础上</div>
                        <div>
                            <input type="text" class="premium" name="premiumVlaue" data-ptype="1">
                            <span class="add-on">元</span>
                        </div>
                    </div>
                    <div>
                        <div style="display:inline-block;float:left">在原价基础上</div>
                        <div>
                            <input type="text" class="premiumPer" name="premiumVlaue" data-ptype="0">
                            <span class="add-on">%</span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="setting-base kawei-maxPrice">
                <div class="option-name">最高出价不高于：</div>
                <div class="option-content">
                    <span class="add-on">￥</span>
                    <input type="text" name="maxPrice">
                </div>
            </div>
            <div class="setting-base">
                <div class="option-name">卡位策略名字：</div>
                <div class="option-content">
                    <input type="text" style="height:30px;width:200px;" name="kaweiName" value="{$tactics.tactics_name}">
                    <input type="hidden" name="path" value="{$tactics.path}">
                    &nbsp;
                </div>
            </div>
        </div>
        <div style="text-align: center">
            <button class="stdbtn previous_page" style="background:#229fdd;color:#fff;padding:8px 30px;margin-right: 15px;">上一步</button>
            <button class="stdbtn save_kawei finish-kawei" style="background:#229fdd;color:#fff;padding:8px 30px;width:98px;">保存</button>
        </div>
    </div>
</div>
<script id="template_selected_keywords" type="text/html">
    <% for(var i in list){ %>
    <tr data-keyword_id="<%= list[i].keyword_id %>" data-campaign_id="<%= list[i].campaign_id %>" data-adgroup_id="<%= list[i].adgroup_id %>">
        <td>
            <a href="javascript:;"><%= list[i].campaign_title %></a>
        </td>
        <td>
            <a href="javascript:;"><%= list[i].item_title %></a>
        </td>
        <td><%= list[i].keyword %></td>
        <td class="real_rank"></td>
        <td>
            <select class="want_rank" name="rankingValue-<%= list[i].keyword_id %>" ></select>
        </td>
        <td>
            <div class="input-prepend">
                <span class="add-on">￥</span>
                <input class="price smallprice currencyinput keyword_price" type="text" name="price" value="<%= list[i].original_price %>" style="width:35px" />
            </div>
        </td>
        <td>
            <a href="javascript:;" class="delete-keyword-btn">取消</a>
        </td>
    </tr>
    <% } %>
</script>
<script type="text/javascript">

    var keyword_id ='{$keyword_id}',
            device = '{$device}',
            keyword_ids ='{$keyword_ids}',
            user_id = {$me['user_id']},
            adgroup_id='{$adgroup_id}',
            tactics_id = '{$tactics_id}',
            campaign_id = '{$campaign_id}';
    $(document).ready(function(){
        var data = {device: device};
        data.keyword_ids = [];
        if(keyword_id){
            data.keyword_ids.push(keyword_id);
        }
        if(keyword_ids){
            var ids = keyword_ids.split(',');
            $.each(ids, function(){
                data.keyword_ids.push(this);
            });
        }
        data.user_id = user_id;
        if(tactics_id){
            data.tactics_id = parseInt(tactics_id, 10);
        }
        data.adgroup_id = adgroup_id?parseInt(adgroup_id, 10):0;
        data.campaign_id = campaign_id?parseInt(campaign_id, 10):0;

        finish_click = ranking.ranking_edit($(document.body), data);
        finish_click.init();

    });

</script>
